const mysql = require('mysql');
//数据库
function __connection() {
	var connection = mysql.createConnection({
		host: '127.0.0.1',
		user: 'root',
		password: '123456',
		database: 'uniapp'
	});
	connection.connect();
	return connection;
}

//回调
exports.query = function(sql, parmas = null) {

	var connection = __connection();
	return new Promise(function(reject, resolve) {
		connection.query(sql, parmas, function(error, results, fields) {
			if (error) throw error;
			reject(results);

		});
		connection.end();
	})
}
